package middleware

import (
	"gin-server/utils/common"
	"github.com/gin-gonic/gin"
)

// Json 全局状态码大于等于400 json格式返回
func Json() gin.HandlerFunc {
	return func(c *gin.Context) {
		c.Next()
		if c.Writer.Status() >= 400 {
			common.JsonError(c, -1, c.Writer.Status())
			return
		}
	}
}
